/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.vsu.cs.piit.vokod.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Галчонок
 */
@Entity
@Table(name = "daily_move")
//@NamedQueries({
//    @NamedQuery(name = "DailyMove.findAll", query = "SELECT d FROM DailyMove d"),
//    @NamedQuery(name = "DailyMove.findByMoveId", query = "SELECT d FROM DailyMove d WHERE d.moveId = :moveId"),
//    @NamedQuery(name = "DailyMove.findByDateOfMove", query = "SELECT d FROM DailyMove d WHERE d.dateOfMove = :dateOfMove"),
//    @NamedQuery(name = "DailyMove.findByMorningCount", query = "SELECT d FROM DailyMove d WHERE d.morningCount = :morningCount"),
//    @NamedQuery(name = "DailyMove.findByEnterAll", query = "SELECT d FROM DailyMove d WHERE d.enterAll = :enterAll"),
//    @NamedQuery(name = "DailyMove.findByEnter018", query = "SELECT d FROM DailyMove d WHERE d.enter018 = :enter018"),
//    @NamedQuery(name = "DailyMove.findByEnterMore60", query = "SELECT d FROM DailyMove d WHERE d.enterMore60 = :enterMore60"),
//    @NamedQuery(name = "DailyMove.findByMoveAtOthers", query = "SELECT d FROM DailyMove d WHERE d.moveAtOthers = :moveAtOthers"),
//    @NamedQuery(name = "DailyMove.findByMoveAtRao", query = "SELECT d FROM DailyMove d WHERE d.moveAtRao = :moveAtRao"),
//    @NamedQuery(name = "DailyMove.findByMoveFromOthers", query = "SELECT d FROM DailyMove d WHERE d.moveFromOthers = :moveFromOthers"),
//    @NamedQuery(name = "DailyMove.findByMoveFromRao", query = "SELECT d FROM DailyMove d WHERE d.moveFromRao = :moveFromRao"),
//    @NamedQuery(name = "DailyMove.findByLeaveAtOthers", query = "SELECT d FROM DailyMove d WHERE d.leaveAtOthers = :leaveAtOthers"),
//    @NamedQuery(name = "DailyMove.findByLeaveHome", query = "SELECT d FROM DailyMove d WHERE d.leaveHome = :leaveHome"),
//    @NamedQuery(name = "DailyMove.findByDied", query = "SELECT d FROM DailyMove d WHERE d.died = :died")})
public class DailyMove implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "move_id", nullable=false)
    private Integer moveId;
    @Column(name = "date_of_move", nullable=false)
    @Temporal(TemporalType.DATE)
    private Date dateOfMove;
    @Column(name = "morning_count", nullable=false)
    private Integer morningCount;
    @Column(name = "enter_all", nullable=false)
    private Integer enterAll;
    @Column(name = "enter_outside", nullable=false)
    private Integer enterOutside;
    @Column(name = "enter_0_18", nullable=false)
    private Integer enter018;
    @Column(name = "enter_more_60", nullable=false)
    private Integer enterMore60;
    @Column(name = "move_at_others", nullable=false)
    private Integer moveAtOthers;
    @Column(name = "move_at_rao", nullable=false)
    private Integer moveAtRao;
    @Column(name = "move_from_others", nullable=false)
    private Integer moveFromOthers;
    @Column(name = "move_from_rao", nullable=false)
    private Integer moveFromRao;
    @Column(name = "leave_at_others", nullable=false)
    private Integer leaveAtOthers;
    @Column(name = "leave_home", nullable=false)
    private Integer leaveHome;
    @Column(name = "died", nullable=false)
    private Integer died;
    @Column(name = "evening_count", nullable=false)
    private Integer eveningCount;
    @Column(name = "evening_count_outside", nullable=false)
    private Integer eveningCountOutside;
    
    @JoinColumn(name = "ward_id", referencedColumnName = "ward_id", nullable=false)
    @ManyToOne(optional = false)
    private Ward ward;

    public DailyMove() {
    }

    public DailyMove(boolean notnull) {
        if (notnull) {
            dateOfMove = new Date();
            died = 0;
            enter018 = 0;
            enterAll = 0;
            enterMore60 = 0;
            enterMore60 = 0;
            enterOutside = 0;
            eveningCount = 0;
            eveningCountOutside = 0;
            leaveAtOthers = 0;
            leaveHome = 0;
            morningCount = 0;
            moveAtOthers = 0;
            moveAtRao = 0;
            moveFromOthers = 0;
            moveFromRao = 0;
        }
    }

    public DailyMove(Integer moveId) {
        this.moveId = moveId;
    }

    public Integer getMoveId() {
        return moveId;
    }

    public void setMoveId(Integer moveId) {
        this.moveId = moveId;
    }

    public Date getDateOfMove() {
        return dateOfMove;
    }

    public void setDateOfMove(Date dateOfMove) {
        this.dateOfMove = dateOfMove;
    }

    public Integer getMorningCount() {
        return morningCount;
    }

    public void setMorningCount(Integer morningCount) {
        this.morningCount = morningCount;
    }

    public Integer getEnterAll() {
        return enterAll;
    }

    public void setEnterAll(Integer enterAll) {
        this.enterAll = enterAll;
    }

    public Integer getEnterOutside() {
        return enterOutside;
    }

    public void setEnterOutside(Integer enterOutside) {
        this.enterOutside = enterOutside;
    }

    public Integer getEnter018() {
        return enter018;
    }

    public void setEnter018(Integer enter018) {
        this.enter018 = enter018;
    }

    public Integer getEnterMore60() {
        return enterMore60;
    }

    public void setEnterMore60(Integer enterMore60) {
        this.enterMore60 = enterMore60;
    }

    public Integer getMoveAtOthers() {
        return moveAtOthers;
    }

    public void setMoveAtOthers(Integer moveAtOthers) {
        this.moveAtOthers = moveAtOthers;
    }

    public Integer getMoveAtRao() {
        return moveAtRao;
    }

    public void setMoveAtRao(Integer moveAtRao) {
        this.moveAtRao = moveAtRao;
    }

    public Integer getMoveFromOthers() {
        return moveFromOthers;
    }

    public void setMoveFromOthers(Integer moveFromOthers) {
        this.moveFromOthers = moveFromOthers;
    }

    public Integer getMoveFromRao() {
        return moveFromRao;
    }

    public void setMoveFromRao(Integer moveFromRao) {
        this.moveFromRao = moveFromRao;
    }

    public Integer getLeaveAtOthers() {
        return leaveAtOthers;
    }

    public void setLeaveAtOthers(Integer leaveAtOthers) {
        this.leaveAtOthers = leaveAtOthers;
    }

    public Integer getLeaveHome() {
        return leaveHome;
    }

    public void setLeaveHome(Integer leaveHome) {
        this.leaveHome = leaveHome;
    }

    public Integer getDied() {
        return died;
    }

    public void setDied(Integer died) {
        this.died = died;
    }

    public Ward getWard() {
        return ward;
    }

    public void setWard(Ward wardId) {
        this.ward = wardId;
    }

    public Integer getEveningCount() {
        return eveningCount;
    }

    public void setEveningCount(Integer eveningCount) {
        this.eveningCount = eveningCount;
    }

    public Integer getEveningCountOutside() {
        return eveningCountOutside;
    }

    public void setEveningCountOutside(Integer eveningCountOutside) {
        this.eveningCountOutside = eveningCountOutside;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (moveId != null ? moveId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DailyMove)) {
            return false;
        }
        DailyMove other = (DailyMove) object;
        if ((this.moveId == null && other.moveId != null) || (this.moveId != null && !this.moveId.equals(other.moveId))) {
            return false;
        }
        return true;
    }

    public boolean isCorrect(){
        if (
                (dateOfMove!=null)&&
                (died!=null)&&
                (enter018!=null)&&
                (enterAll!=null)&&
                (enterMore60!=null)&&
                (enterOutside!=null)&&
                (eveningCount!=null)&&
                (eveningCountOutside!=null)&&
                (leaveAtOthers!=null)&&
                (leaveHome!=null)&&
                (morningCount!=null)&&
                (moveAtOthers!=null)&&
                (moveAtRao!=null)&&
                (moveFromOthers!=null)&&
                (moveFromRao!=null)&&
                (ward!=null)
           )
            return true;
        return false;
    }

    @Override
    public String toString() {
        return "ru.vsu.cs.vsu.piit.vokod.model.DailyMove[moveId=" + moveId + "]";
    }

}
